﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ItsPdfGUI.Properties;
using ItsPdfUtils;

namespace ItsPdfGUI
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void btnPdf2SignBrowse_Click(object sender, EventArgs e)
		{
			this.openFileDialogPdf2Sign.FileName = this.txtPdf2Sign.Text;
			if (this.openFileDialogPdf2Sign.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				this.txtPdf2Sign.Text = this.openFileDialogPdf2Sign.FileName;
				Settings.Default.Save();
			}
		}

		private void btnSign_Click(object sender, EventArgs e)
		{
			SignatureUtils.Sign(this.comboCertificates.SelectedItem as CertificateItem, 1, this.txtPdf2Sign.Text, Path.GetFileNameWithoutExtension(this.txtPdf2Sign.Text) + ".singed.pdf", "Jan Vilimek");
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			var citems = this.comboCertificates.Items;
			citems.Clear();
			var list = SignatureUtils.GetAvailableCertificates();
			foreach (var c in list)
			{
				citems.Add(c);
			}

		}
	}
}
